namespace Akso.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class Add_Course_And_CourseSchedule_Entities : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Edu_Courses",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        TenantId = c.Int(nullable: false),
                        CourseName = c.String(nullable: false, maxLength: 50),
                        IsAutoCreateName = c.Boolean(nullable: false),
                        Years = c.Int(nullable: false),
                        Period = c.String(maxLength: 20),
                        PeriodGUID = c.Guid(),
                        Grade = c.String(maxLength: 50),
                        GradeGUID = c.Guid(),
                        Subject = c.String(maxLength: 50),
                        SubjectGUID = c.Guid(),
                        SubjectType = c.String(maxLength: 50),
                        SubjectTypeGUID = c.Guid(),
                        IsQK = c.Boolean(nullable: false),
                        ChargeType = c.String(maxLength: 50),
                        IsAnQi = c.Boolean(nullable: false),
                        ChargeTime = c.Int(nullable: false),
                        Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                        CourseType = c.String(maxLength: 50),
                        CourseTypeGuid = c.Guid(),
                        IsDisable = c.Boolean(nullable: false),
                        Remark = c.String(maxLength: 500),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_CourseEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Edu_CourseSchedules",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Chapter = c.String(nullable: false, maxLength: 20),
                        Content = c.String(maxLength: 100),
                        CourseID = c.Guid(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseScheduleEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Edu_Courses", t => t.CourseID, cascadeDelete: true)
                .Index(t => t.CourseID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Edu_CourseSchedules", "CourseID", "dbo.Edu_Courses");
            DropIndex("dbo.Edu_CourseSchedules", new[] { "CourseID" });
            DropTable("dbo.Edu_CourseSchedules",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseScheduleEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Edu_Courses",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_CourseEntity_MustHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_CourseEntity_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
        }
    }
}
